const express = require('express');
const router = express.Router();
const url = require('url');
const bodyParser = require('body-parser');
const useBodyParser = bodyParser.urlencoded({
    extended: true,
});
const app = express();
app.use(useBodyParser);

router.get('/home', (req, res) => {
    const paramsUrl = url.parse(req.url);
    console.log('req.url->', paramsUrl);
    res.send({
        data: [{ name: 'get' }, { name: 'get' }, { name: 'get' }, { name: 'get' }, { name: 'get' }],
        msg: '请求数据成功',
        statusCode: 200,
    });
});

router.post('/user', (req, res) => {
    console.log('req.url->', req.body);
    res.send({
        data: [
            { name: 'post' },
            { name: 'post' },
            { name: 'post' },
            { name: 'post' },
            { name: 'post' },
        ],
        msg: '请求数据成功',
        statusCode: 200,
    });
});
module.exports = router;
